<template>
	<view class="show-where">
		<block v-if="userInfo.role_type!=2 && userInfo.role_type!=11">
			<view :class="['merchants']">
				<view class="merchants-contents">
					<view class="merchants-contents-swiper">
						<swiper class="swiper" :indicator-dots="true" :autoplay="true" :interval="3000" :circular="true" indicator-active-color="#007aff">
							<swiper-item v-for="(data,index) in bannerList" :key="index">
								<image :src="data.image" mode="widthFix"></image>
							</swiper-item>
						</swiper>
					</view>
					<view class="merchants-contents-1"><image src="https://master.shengejiaju.cn/web/static/images/pic_trait.png" mode="widthFix"></image></view>
					<view class="merchants-contents-2">
						<image src="https://master.shengejiaju.cn/web/static/images/bg_pic.png" mode="widthFix"></image>
						<view class="merchants-2-box">
							<view class="merchants-2-box-logo"><image src="https://master.shengejiaju.cn/web/static/images/fm_logo.png" mode="widthFix"></image></view>
							<view class="merchants-2-box-tit">企业介绍 <text>Company introduction</text></view>
							<view class="merchants-2-box-txt">团队10年家具零售经验、5年生产制造经验，厚重的选品能力、品控能力和设计能力积索</view>
							<view class="merchants-2-box-txt">家具大师创立3年，为一件优质低价的好家居，团队足迹踏遍广东、浙江、江苏、四川、山东、马来西亚、越南、意大利等全球核心家具产业带</view>
							<view class="merchants-2-box-txt">从500多家工厂中，严选出100家工厂</view>
							<view class="merchants-2-box-txt">从数十万个SKU中，严选出10000多款家居好产品并精心梳理出8大风格，以符合不同客群的消费偏好</view>
							<view class="merchants-2-box-btn"><text @click="contactServer">马上合作</text></view>
						</view>
					</view>
					<view class="merchants-contents-3"><image src="https://master.shengejiaju.cn/web/static/images/Why_choose_us.png" mode="widthFix"></image></view>
					<view class="merchants-contents-4">
						<image src="https://master.shengejiaju.cn/web/static/images/title02.png" mode="widthFix" class="title02"></image>
						<view class="merchants-contents-4-info">
							<image src="https://master.shengejiaju.cn/web/static/images/text.png" mode="widthFix"></image>
							<view class="merchants-4-btn" v-if="isAudit">
								<view><text @click="goSupplier">成为供应商</text></view>
								<view><text @click="goDealer">成为经销商</text></view>
							</view>
						</view>
					</view>
					<view class="merchants-contents-5">
						<image src="https://master.shengejiaju.cn/web/static/images/title03.png" mode="widthFix" class="tit"></image>
						<image src="https://master.shengejiaju.cn/web/static/images/text02.png" mode="widthFix"></image>
					</view>
					<view class="merchants-contents-6">
						<image src="https://master.shengejiaju.cn/web/static/images/title04.png" mode="widthFix" class="tit"></image>
						<tabs :list="style_list" v-model="caseActive" @input="selectCaseSort"></tabs>
						<view class="case-list">
							<view class="case-item" v-for="(data,index) in CaseList" :key="index">
								<image :src="data.image_middle" mode="widthFix"></image>
								<view class="case-item-tit">{{data.case_name}}</view>
								<view class="case-item-brief">{{data.brief}}</view>
								<view class="case-item-des">{{data.style_name}} | {{data.space}} | {{data.square}}㎡</view>
							</view>
							<no-more :text="'暂无数据'" v-if="!CaseList.length"></no-more>
							<no-more :text="'数据加载完毕'" v-if="CaseList.length && noMore"></no-more>
						</view>
					</view>
				</view>
				<view class="server-icon" @click="contactServer"><image src="https://master.shengejiaju.cn/web/static/images/server.png" mode="widthFix"></image></view>
				<view class="login" v-if="!userInfo.role_type"><button type="primary" @click="login" hover-class="">立即登录</button></view>
				<view class="login" v-else><button type="primary" @click="loginOut" hover-class="">退出登录</button></view>
				<uni-popup type="center" ref="serverPop">
					<view class="serverPop">
						<view class="serverPop-tit">联系客服</view>
						<view><image :src="service_img" @longtap="toSave"></image></view>
						<view class="tips">长按即可保存二维码</view>
						<view><text @click="phoneCall">立即呼叫</text></view>
					</view>
				</uni-popup>
			</view>
		</block>
		<block v-if="userInfo.role_type==2 || userInfo.role_type==11">
			<!-- #ifdef APP-PLUS || H5 -->
			<view class="index">
			<!-- #endif -->
			<!-- #ifdef MP-WEIXIN -->
			<view class="index" :style="'padding-top:'+ (allHeight + height - 10) + 'px'">
			<!-- #endif -->
				<!-- #ifdef APP-PLUS || H5 -->
				<view class="index-top">
					<image :src="userInfo.store_logo?userInfo.store_logo:'https://master.shengejiaju.cn/web/static/icons/shop-default.png'"></image>
					{{userInfo.store_name?userInfo.store_name:'未设置店铺名称'}}
				</view>
				<!-- #endif -->
				<!-- #ifdef MP-WEIXIN -->
				<view class="index-top" :style="'padding-top:' + height + 'px'">
					<image :src="userInfo.store_logo?userInfo.store_logo:'https://master.shengejiaju.cn/web/static/icons/shop-default.png'"></image>
					{{userInfo.store_name?userInfo.store_name:'未设置店铺名称'}}
				</view>
				<!-- #endif -->
				<!-- <view class="index-item index-item-1" @click="goData">
					<view class="index-item-1-tag">
						查看店铺更多数据
						<image src="https://master.shengejiaju.cn/web/static/icons/ico_more_data.png" mode="aspectFit"></image>
					</view>
					<view class="index-item-1-tit">今日业绩</view>
					<view class="index-item-1-list">
						<view class="index-item-1-item">
							<view>支付订单数</view>
							<text>{{todayData.orderMoney.today.order_num}}</text>
						</view>
						<view class="index-item-1-item">
							<view>支付金额(元)</view>
							<text>{{todayData.orderMoney.today.price}}</text>
						</view>
						<view class="index-item-1-item">
							<view>利润(元)</view>
							<text>{{todayData.orderMoney.today.profit}}</text>
						</view>
						<view class="index-item-1-item">
							<view>累计收益（元）</view>
							<text>{{todayData.shopMoney.history_money}}</text>
						</view>
						<view class="index-item-1-item">
							<view>待到账（元）</view>
							<text>{{todayData.shopMoney.take_money}}</text>
						</view>
						<view class="index-item-1-item">
							<view>余额（元）</view>
							<text>{{todayData.shopMoney.money}}</text>
						</view>
					</view>
				</view>
				<view class="index-item index-item-2" v-if="growList.length">
					<view class="index-item-tit">
						<view>商家成长</view>
						<view>
							<navigator url="/pages/growing/growing">更多<image src="https://master.shengejiaju.cn/web/static/icons/ico_more_home@2x.png"></image></navigator>
						</view>
					</view>
					<view class="index-item-2-list">
						<view class="index-item-2-item" v-for="(data,index) in growList" :key="index">
							<navigator :url="'/pages/growing/growing-info?type='+ data.sort">
								<view class="index-item-2-item-image"><image :src="data.logo"></image></view>
								<view class="index-item-2-item-info">
									<view>{{data.name}}</view>
									<text>{{data.brief}}</text>
								</view>
								<view class="index-item-2-item-arrow">
									<text :class="['tag',{gary: data.is_succeed!=0}]">{{data.is_succeed==0?'未完成':'已完成'}}</text>
									<image src="https://master.shengejiaju.cn/web/static/icons/ico_more_home@2x.png"></image>
								</view>
							</navigator>
						</view>
					</view>
				</view> -->
				
				<view class="index-item index-item-3">
					<view class="index-item-tit">
						<view>店铺中心</view>
					</view>
					<view class="index-item-3-list">
						<!-- <view class="index-item-3-item">
							<navigator url="/pages/my/store-settings">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_shop_mag@2x.png"></image></view>
								<text>店铺管理</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/product-manage/product-manage">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_distrbition@2x.png"></image></view>
								<text>商品管理</text>
							</navigator>
						</view> -->
						<view class="index-item-3-item">
							<navigator url="/pages/order/shop/shop">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_Order@2x.png"></image></view>
								<text>店铺订单</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/order/purchase/purchase">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_jh_goods@2x.png"></image></view>
								<text>进货订单</text>
							</navigator>
						</view>
						<!-- <view class="index-item-3-item">
							<navigator url="/pages/product-manage/product-manage?is_package=1">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_setmall@2x.png"></image></view>
								<text>套餐管理</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/case-manage/case-manage">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_case@2x.png"></image></view>
								<text>案例管理</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/desiger-manage/desiger-manage">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_designer@2x.png"></image></view>
								<text>设计师管理</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/video-manage/video-manage">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_vedio@2x.png"></image></view>
								<text>视频管理</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/carousel-manage/carousel-manage">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_wheel@2x.png"></image></view>
								<text>轮播管理</text>
							</navigator>
						</view> -->
						<view class="index-item-3-item">
							<navigator url="/pages/staff/staff">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_banner@2x.png"></image></view>
								<text>人员管理</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/my/poster-list/poster-list">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_goods_mag@2x.png"></image></view>
								<text>我的海报</text>
							</navigator>
						</view>
						<!-- <view class="index-item-3-item">
							<navigator url="/pages/platform-goods/platform-category">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_plat@2x.png"></image></view>
								<text>平台商品</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/activity/activity">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_activity@2x.png"></image></view>
								<text>活动管理</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/coupon/coupon">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_coupon@2x.png"></image></view>
								<text>优惠券</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/customer/customer">
								<view><image src="https://master.shengejiaju.cn/web/static/icons/index/ico_customer@2x.png"></image></view>
								<text>意向客户</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/course/course">
								<view><image src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/static/images/other/2021-04-08/20210408/bd3a9b2857a9a78614767ce312e0e18d.png"></image></view>
								<text>使用手册</text>
							</navigator>
						</view>
						<view class="index-item-3-item">
							<navigator url="/pages/index/home-sort">
								<view><image src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/static/images/other/2021-09-25/20210925/3097b34623c5c756e41472cb63189c47.png"></image></view>
								<text>首页排序</text>
							</navigator>
						</view> -->
					</view>
				</view>
				<view class="index-item index-item-5">
					<view class="index-item-tit">
						<view>用户动态</view>
						<view>
							<navigator url="/pages/index/user-dynamic">更多<image src="https://master.shengejiaju.cn/web/static/icons/ico_more_home@2x.png"></image></navigator>
						</view>
					</view>
					<block v-if="BrowseUserList.length">
						<view class="index-item-5-list">
							<view class="index-item-5-item" v-for="(data,index) in BrowseUserList" :key="index" @click="goInfo(data.user_id,0)">
								<view class="index-item-5-item-top">
									<image :src="data.heard_img"></image>
									<view class="index-item-5-item-top-left">
										<view class="top">{{data.nickname}} <text class="time">{{data.add_time}}</text></view>
										<view class="bottom">
											ID:{{data.user_id}} 
											<text>
												<text v-if="data.type==1">小程序：</text>
												<text v-if="data.type==2">APP：</text>
												<text v-if="data.type==3">H5：</text>
												<text v-if="data.type==4">PC：</text>
												<text v-if="data.type==5">Ipad：</text>
												<text v-if="data.type==6">后台系统：</text>
												{{data.num}}次
											</text>
										</view>
									</view>
								</view>
								<view class="index-item-5-item-bottom">
									<text>TA：{{data.foot_where}}</text>
									<button plain type="primary" size="mini">查看详情</button>
								</view>
							</view>
						</view>
					</block>
					<block v-else>
						<no-more :text="'暂无数据'" style="margin-top: 40rpx;"></no-more>
					</block>
				</view>
				<view class="index-item index-item-5">
					<view class="index-item-tit">
						<view>用户足迹</view>
						<view>
							<navigator url="/pages/index/user-footprint">更多<image src="https://master.shengejiaju.cn/web/static/icons/ico_more_home@2x.png"></image></navigator>
						</view>
					</view>
					<block v-if="BrowseList.length">
						<view class="index-item-5-list">
							<view class="index-item-5-item" v-for="(data,index) in BrowseList" :key="index" @click="goInfo(data.user_id,1)">
								<view class="index-item-5-item-top">
									<image :src="data.heard_img"></image>
									<view class="index-item-5-item-top-left">
										<view class="top">{{data.nickname}} <text class="time">{{data.add_time}}</text></view>
										<view class="bottom">
											ID:{{data.user_id}} 
											<text>
												<text v-if="data.type==1">小程序</text>
												<text v-if="data.type==2">APP</text>
												<text v-if="data.type==3">H5</text>
												<text v-if="data.type==4">PC</text>
												<text v-if="data.type==5">Ipad</text>
												<text v-if="data.type==6">后台系统</text>
											</text>
										</view>
									</view>
								</view>
								<view class="index-item-5-item-bottom footprint-goods">
									<image :src="data.image_middle"></image>
									<view class="index-item-5-item-bottom-info">
										<view class="title">{{data.goods_name}}</view>
										<view class="price">￥<text>{{data.retail_price}}</text></view>
										<view class="times">浏览次数:{{data.num}}次</view>
										<button plain type="primary" size="mini">查看详情</button>
									</view>
								</view>
							</view>
						</view>
					</block>
					<block v-else>
						<no-more :text="'暂无数据'" style="margin-top: 40rpx;"></no-more>
					</block>
				</view>
				<view class="index-item index-item-6">
					<view class="index-item-tit">
						<view>订单数据</view>
					</view>
					<view class="index-item-6-list">
						<view class="index-item-6-item" @click="goOrderList(0)">
							<view>本月订单数</view>
							<text>{{orderData.month.all?orderData.month.all:0}}</text>
						</view>
						<view class="index-item-6-item" @click="goOrderList(0)">
							<view>上月订单数</view>
							<text>{{orderData.last_month.all?orderData.last_month.all:0}}</text>
						</view>
						<view class="index-item-6-item" @click="goOrderList(0)">
							<view>历史订单</view>
							<text>{{orderData.all.all?orderData.all.all:0}}</text>
						</view>
						<view class="index-item-6-item" @click="goOrderList(3)">
							<view>待发货</view>
							<text>{{orderData.wait_order}}</text>
						</view>
						<view class="index-item-6-item" @click="goOrderList(4)">
							<view>待收货</view>
							<text>{{orderData.wait_success}}</text>
						</view>
						<view class="index-item-6-item" @click="goOrderList(2)">
							<view>待确认</view>
							<text>{{orderData.wait_See}}</text>
						</view>
					</view>
				</view>
				<view class="index-item index-item-6">
					<view class="index-item-tit">
						<view>产品数据</view>
					</view>
					<view class="index-item-6-list">
						<view class="index-item-6-item">
							<view>平台商品总数</view>
							<text>{{proData.all}}</text>
						</view>
						<!-- <view class="index-item-6-item">
							<view>自营商品(上架)</view>
							<text>{{proData.on_sale}}</text>
						</view>
						<view class="index-item-6-item">
							<view>自营商品(下架)</view>
							<text>{{proData.out_sale}}</text>
						</view> -->
					</view>
				</view>
				<!-- <view class="index-item index-item-6">
					<view class="index-item-tit">
						<view>业绩数据</view>
					</view>
					<view class="index-item-6-list" @click="goData">
						<view class="index-item-6-item">
							<view>上月业绩</view>
							<text><text>¥</text>{{moneyData.last_month.profit}}</text>
						</view>
						<view class="index-item-6-item">
							<view>本月业绩</view>
							<text><text>¥</text>{{moneyData.month.profit}}</text>
						</view>
						<view class="index-item-6-item">
							<view>历史业绩</view>
							<text><text>¥</text>{{moneyData.all.profit}}</text>
						</view>
					</view>
				</view> -->
				<view class="index-item index-item-6">
					<view class="index-item-tit">
						<view>人员数据</view>
					</view>
					<navigator url="/pages/staff/staff">
						<view class="index-item-6-list">
							<view class="index-item-6-item" style="width: 25%;">
								<view>普通用户</view>
								<text>{{counts.user1}}</text>
							</view>
							<view class="index-item-6-item" style="width: 25%;">
								<view>业务员</view>
								<text>{{counts.user2}}</text>
							</view>
							<view class="index-item-6-item" style="width: 25%;">
								<view>财务</view>
								<text>{{counts.user3}}</text>
							</view>
							<view class="index-item-6-item" style="width: 25%;">
								<view>分销商</view>
								<text>{{counts.user4}}</text>
							</view>
						</view>
					</navigator>
				</view>
			</view>
		</block>
		<uni-popup type="center" ref="Update" :maskClick="false">
			<view class="update-pop">
				<view class="update-close"><image src="https://master.shengejiaju.cn/web/static/icons/ico_closed002.png" @click="closeUpdate"></image></view>
				<image src="https://master.shengejiaju.cn/web/static/images/update.png" mode="widthFix" class="update-img"></image>
				<view class="update-main">
					<view class="update-tit">更新内容：</view>
					<view class="update-p" v-for="(data,index) in updateContent" :key="index">{{data}}</view>
					<button type="primary" class="download" @click="update">更新版本</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import format from '@/components/shoyu-date/utils.filter.js';
	export default {
		data() {
			return {
				bannerList: [],
				Refresh: false,
				userInfo: {},
				// 今日业绩
				todayData: {
					orderMoney: {
						today: {},
						yestoday: {}
					},
					shopMoney: {}
				},
				// 订单数据
				orderData: {
					all: {},
					last_month: {},
					last_week: {},
					last_year: {},
					month: {},
					today: {},
					wait_See: 0,
					wait_order: 0,
					wait_success: 0,
					week: {},
					year: {},
					yesterday: {}
				},
				// 产品数据
				proData: {
					all: 0,
					on_sale: 0,
					out_sale: 0
				},
				// 业绩数据
				moneyData: {
					all: {
						profit: 0
					},
					last_month: {
						profit: 0
					}, 
					month: {
						profit: 0
					}
				},
				// 人员数据
				personnelData: {
					distribution_num: 0,
					service_num: 0,
					user_num: 0
				},
				// 店铺排行榜
				storeRankList: [],
				// 足迹
				BrowseUserList: [],
				BrowseList: [],
				// 商家成长
				growList: [],
				service_img: '',
				service_phone: '',
				counts: {
					user1: 0,
					user2: 0,
					user3: 0,
					user4: 0
				},
				// 优选案例列表
				page: 0,
				noMore: false,
				caseActive: 0,
				style_list: [],
				CaseList: [],
				height: '',
				allHeight: '',
				isAudit: true,
				updateContent: [],
				downLoadUrl: ''
			}
		},
		onLoad() {
			uni.hideTabBar()
			this.$api.HomeWeChat().then(res => {
				this.service_img = res.datas.service_img
				this.service_phone = res.datas.service_phone
				if(res.datas.is_show_store_app==2){
					this.isAudit = false
				}
			})
			this.getCaseSort()
			this.getCase()
			this.$api.slideshow_list({client: 7}).then(res => {
				this.bannerList = res.datas
			})
		},
		onShow() {
			this.getUpload()
			if(uni.getStorageSync('userInfo')){
				this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
				if(this.userInfo.role_type==2 || this.userInfo.role_type==11){
					uni.showTabBar()
					this.getTodayResult()
					this.getOrderData()
					this.getProData()
					this.getUserData()
					// this.getStoreRank()
					this.getBrowseList()
					this.getUserInfo()
					this.getGrowLists()
					// #ifdef MP-WEIXIN
					let _this = this
					this.$nextTick(() => {
						if(uni.getStorageSync('userInfo')){
							this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
							if(this.userInfo.role_type==2 || this.userInfo.role_type==11){
								let menuButtonObject = uni.getMenuButtonBoundingClientRect()
								this.height = menuButtonObject.top
								let info = uni.createSelectorQuery().select(".index-top");
								info.boundingClientRect(function(data) {
									_this.allHeight = data.height
								}).exec()
							}
						}
					},200)
					// #endif
				}
			}
		},
		onPullDownRefresh() {
			if(this.userInfo.role_type==2 || this.userInfo.role_type==11){
				this.Refresh = true
				this.refresh()
			}else{
				this.$api.HomeWeChat().then(res => {
					this.service_img = res.datas.service_img
					this.service_phone = res.datas.service_phone
				})
				this.getCaseSort()
				this.getCase()
				this.$api.slideshow_list({client: 7}).then(res => {
					this.bannerList = res.datas
					setTimeout(() => {
						uni.stopPullDownRefresh({
							success(){
								uni.showToast({
									icon: 'none',
									title: '刷新成功',
									duration: 1500
								})
							}
						})
					},1000)
				})
			}
		},
		onReachBottom() {
			if(!uni.getStorageSync('userInfo') || uni.getStorageSync('userInfo') && this.userInfo.role_type!=2 && this.userInfo.role_type!=11){
				if(!this.noMore){
					this.page++
					this.getCase()
				}
			}
		},
		methods: {
			// APP升级检测
			getUpload(){
				//#ifdef APP-PLUS
				let _this = this
				let version = ''
				plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo){
						version = wgtinfo.version
						let req = { //升级检测数据
							"appid": plus.runtime.appid,
							"version": version
						};
						_this.$api.appUpdate().then(res => {
							if(res.datas.ver!==version){
								if (res.datas.flag && res.datas.wgtUrl) {
									uni.showLoading({
										mask: true,
										title: '正在更新'
									})
									uni.downloadFile({
										url: res.datas.wgtUrl,
										success: (downloadResult) => {
											if (downloadResult.statusCode === 200) {
												plus.runtime.install(downloadResult.tempFilePath, {
													force: false
												}, function(e) {
													uni.hideLoading()
													plus.runtime.restart();
												}, function(e) {
													uni.hideLoading()
													uni.showToast({
														icon: 'none',
														title: '由于未知原因，自动更新失败，请删除应用后重新下载，'+e
													})
													console.log('自动更新失败,请删除应用后重新下载',e);
												})
											}
										},
										fail: (fail) => {
											uni.showToast({
												icon: 'none',
												title: '由于未知原因，自动更新失败，请删除应用后重新下载，'+fail
											})
										}
									})
								}else if(res.datas.flag && res.datas.pkgUrl){
									_this.downLoadUrl = res.pkgUrl
									_this.updateContent = res.datas.content
									_this.$refs.Update.open()
								}
							}
						})
				});
				//#endif
			},
			getUserInfo(){
				this.$api.UserInfo().then(res => {
					if(this.userInfo.ios){
						this.userInfo.role_type = 2
					}else{
						this.userInfo = {
							user_id: res.datas.user_id,
							heard_img: res.datas.heard_img,
							nickname: res.datas.nickname,
							store_id: res.datas.store_id,
							store_logo: res.datas.store_logo,
							store_name: res.datas.store_name,
							role_type: res.datas.role_type
						}
					}
				})
			},
			getCaseSort(){
				this.$api.CaseList({type: 1,activity: 785}).then(res => {
					if(res.datas.style_list.length){
						res.datas.style_list.forEach(item => {
							this.style_list.push({
								id: item.style_id,
								title: item.style_name
							})
						})
					}
					this.style_list.unshift({
						id: '',
						title: '全部'
					})
				})
			},
			getCase(style_id){
				this.$api.CaseList({type: 1,limit: 5,activity: 785,page: this.page?this.page:0,style_id: style_id?style_id:''}).then(res => {
					if(res.datas.list.length){
						res.datas.list.forEach(item => {
							this.CaseList.push(item)
						})
					}else{
						this.noMore = true
					}
				})
			},
			selectCaseSort(e){
				this.page = 0
				this.noMore = false
				this.CaseList = []
				this.getCase(this.style_list[e].id)
			},
			refresh(){
				this.getTodayResult()
				this.getOrderData()
				this.getProData()
				this.getUserData()
				// this.getStoreRank()
				this.getBrowseList()
				this.getGrowLists()
			},
			// 跳转数据页面
			goData(){
				uni.switchTab({
					url: '/pages/data/data'
				})
			},
			// 获取业绩数据
			getTodayResult(){
				let data = {
					store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id,
					day: 5
				}
				let data1 = {
					store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id
				}
				this.$api.MoneyContrastData(data).then(res => {
					this.todayData.orderMoney.today = res.datas.today
					this.moneyData.all.profit =  res.datas.all.profit
					this.moneyData.last_month.profit = res.datas.last_month.profit
					this.moneyData.month.profit = res.datas.month.profit
				}).then(res => {
					this.$api.GetStoreMoney(data1).then(shopRes => {
						this.todayData.shopMoney = shopRes.datas
					})
				})
			},
			// 获取订单数据
			getOrderData(){
				let data = {
					store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id,
					day: 5
				}
				this.$api.OrderContrastData(data).then(res => {
					this.orderData = res.datas
				})
			},
			// 获取产品数据
			getProData(){
				let data = {
					store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id
				}
				this.$api.HomeGoodsData(data).then(res => {
					this.proData = res.datas
				})
			},
			// 获取人员数据
			getUserData(){
				this.$api.StaffCount({store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id}).then(res => {
					this.counts.user1 = res.datas.user1
					this.counts.user2 = res.datas.user2
					this.counts.user3 = res.datas.user3
					this.counts.user4 = res.datas.user4
				})
			},
			// 获取店铺排行榜
			getStoreRank(){
				this.$api.OrderListData({limit: 5,page: 0,day: 1,goods_store_id: 1}).then(res => {
					this.storeRankList = res.datas.list
				})
			},
			// 获取用户足迹
			getBrowseList(){
				this.$api.BrowseUserList({limit: 5, store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id,group: 1,is_new: 1}).then(res => {
					this.BrowseUserList = res.datas.list
				})
				this.$api.BrowseItems({limit: 5, store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id,paramter: 1,group: 1,is_new: 1}).then(res => {
					this.BrowseList = res.datas.list
				})
			},
			// 获取商家成长
			getGrowLists(){
				this.$api.GrowLists({store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id,home: 1,limit: 3}).then(res => {
					this.growList = res.datas
					let _this = this
					if(this.Refresh){
						setTimeout(() => {
							uni.stopPullDownRefresh({
								success(){
									_this.Refresh = false
									uni.showToast({
										icon: 'none',
										title: '刷新成功',
										duration: 1500
									})
								}
							})
						},1000)
					}
				})
			},
			// 跳转用户动态&&足迹详情
			goInfo(user_id,type){
				uni.navigateTo({
					url: '/pages/index/user-dynamic-info?user_id='+user_id+'&type='+type
				})
			},
			goOrderList(type){
				uni.setStorageSync('orderType',type)
				uni.switchTab({
					url: '/pages/order/order'
				})
			},
			login(){
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			contactServer(){
				this.$refs.serverPop.open()
			},
			phoneCall(){
				uni.makePhoneCall({
					phoneNumber: this.service_phone.toString(),
					fail(callFail) {
						console.log(callFail)
					}
				})
			},
			save() {
				uni.getImageInfo({
					src: this.service_img,
					success: function(image) {
						uni.saveImageToPhotosAlbum({
							filePath: image.path,
							success: function() {
								uni.showToast({
									title: '图片保存成功',
									icon: 'none',
									duration: 2200
								});
							}
						});
					}
				});
			},
			toSave() {
				uni.showModal({
					title: '图片保存',
					content: '确定要保存图片吗',
					success: e => {
						if (e['confirm']) {
							this.save();
						}
					}
				});
			},
			loginOut(){
				uni.clearStorageSync('userInfo')
				uni.showToast({
					icon: 'none',
					title: '退出成功',
					duration: 1500
				})
				setTimeout(() => {
					this.userInfo = {}
				},1500)
			},
			goSupplier(){
				if(!this.userInfo.role_type){
					uni.showToast({
						icon: 'none',
						title: '请先登录',
						duration: 1500
					})
					return false
				}
				uni.navigateTo({
					url: '/pages/index/supplier'
				})
			},
			goDealer(){
				if(!this.userInfo.role_type){
					uni.showToast({
						icon: 'none',
						title: '请先登录',
						duration: 1500
					})
					return false
				}
				uni.navigateTo({
					url: '/pages/index/dealer'
				})
			},
			// 点击更新
			update(){
				if(uni.getSystemInfoSync().platform==='ios'){
					plus.runtime.openURL('itms-apps://itunes.apple.com/cn/app/id1521128039?mt=8');
				}else{
					plus.runtime.openURL(this.downLoadUrl);
				}
			},
			// 关闭更新提醒
			closeUpdate(){
				this.$refs.Update.close()
			}
		}
	}
</script>
<style lang="scss">
	page{
		min-height: 100%;
	}
	@import '../../static/scss/index.scss';
	.index{
		/* #ifdef APP-PLUS */
		padding-top: 140rpx;
		/* #endif */
		/* #ifdef H5 */
		padding-top: 100rpx;
		/* #endif */
	}
	.index-top{
		/* #ifdef APP-PLUS */
		padding: 45rpx 25rpx 5rpx;
		height: 140rpx;
		/* #endif */
		/* #ifdef MP-WEIXIN */
		padding: 45rpx 25rpx 20rpx;
		/* #endif */
		/* #ifdef H5 */
		padding: 5rpx 25rpx 5rpx;
		height: 100rpx;
		/* #endif */
	}
	.merchants{
		padding-bottom: 90rpx;
		&.pd0{
			padding-bottom: 0;
		}
		.merchants-contents {
			.merchants-contents-swiper{
				margin-bottom: 20rpx;
				box-shadow: 0px 10rpx 16rpx 0px rgba(4,0,0,0.2);
			}
			.merchants-contents-1{
				background-color: #FFF;
				height: 110rpx;
				line-height: 110rpx;
				padding: 0 50rpx;
				image{
					vertical-align: middle;
				}
			}
			.merchants-contents-2{
				box-shadow: 0px 10rpx 16rpx 0px rgba(4,0,0,0.2);
				position: relative;
				margin-bottom: 20rpx;
				.merchants-2-box{
					position: absolute;
					background-color: rgba(255,255,255,.7);
					top: 20rpx;
					left: 20rpx;
					bottom: 20rpx;
					right: 20rpx;
					padding: 30rpx;
					.merchants-2-box-logo{
						image{
							width: 253rpx;
						}
					}
					.merchants-2-box-tit{
						font-size: 30rpx;
						color: #333;
						font-weight: bold;
						padding: 40rpx 0;
						border-bottom: dashed 1px #C7C7C7;
						text{
							font-weight: normal;
							font-size: 18rpx;
							color: #999;
							margin-left: 20rpx;
							text-transform: uppercase;
						}
					}
					.merchants-2-box-txt{
						margin-top: 35rpx;
						font-size: 26rpx;
						color: #666;
						line-height: 40rpx;
					}
					.merchants-2-box-btn{
						text-align: center;
						margin-top: 40rpx;
						text{
							display: inline-block;
							height: 80rpx;
							line-height: 80rpx;
							background: linear-gradient(90deg,rgba(22,172,255,1),rgba(7,130,255,1));
							border-radius: 40px;
							font-size: 32rpx;
							color: #FFF;
							padding: 0 130rpx;
						}
					}
				}
			}
			.merchants-contents-3{
				box-shadow: 0px 10rpx 16rpx 0px rgba(4,0,0,0.2);
			}
			.merchants-contents-4{
				box-shadow: 0px 10rpx 16rpx 0px rgba(4,0,0,0.2);
				margin-bottom: 20rpx;
				.title02{
					margin: 20rpx 0;
				}
				.merchants-contents-4-info{
					background-color: #FFF;
					padding: 50rpx 0;
					.merchants-4-btn{
						display: flex;
						padding: 50rpx 50rpx 0;
						justify-content: center;
						view{
							width: 300rpx;
							height: 80rpx;
							line-height: 80rpx;
							text-align: center;
							background: linear-gradient(90deg,rgba(22,172,255,1),rgba(7,130,255,1));
							font-size: 32rpx;
							border-radius: 40rpx;
							color: #FFF;
							&:first-child{
								position: relative;
								color: #128BFF;
								margin-right: 20rpx;
								text{
									position: relative;
									z-index: 1;
								}
								&::after{
									content: '';
									position: absolute;
									left: 4rpx;
									top: 4rpx;
									bottom: 4rpx;
									right: 4rpx;
									background-color: #FFF;
									border-radius: 40rpx;
								}
							}
						}
					}
				}
			}
			.merchants-contents-5{
				box-shadow: 0px 10rpx 16rpx 0px rgba(4,0,0,0.2);
				margin-bottom: 20rpx;
				.tit{
					margin-bottom: 20rpx;
				}
			}
			.merchants-contents-6{
				box-shadow: 0px 10rpx 16rpx 0px rgba(4,0,0,0.2);
				margin-bottom: 20rpx;
				.tit{
					margin-bottom: 20rpx;
				}
				/deep/ .case-list{
					background-color: #FFF;
					.case-item{
						padding: 20rpx;
						.case-item-tit{
							margin-top: 20rpx;
							font-size: 36rpx;
						}
						.case-item-brief{
							font-size: 28rpx;
							margin-top: 20rpx;
							color: #666;
						}
						.case-item-des{
							margin-top: 20rpx;
							font-size: 26rpx;
							color: #999;
						}
					}
					.no-more{
						padding-top: 40rpx;
					}
				}
			}
			.swiper{
				height: 1100rpx;
			}
			image{
				width: 100%;
				vertical-align: top;
			}
		}
		.login{
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;
			z-index: 99;
			button{
				height: 90rpx;
				line-height: 90rpx;
				font-size: 30rpx;
				border-radius: 0;
			}
		}
		.server-icon{
			position: fixed;
			bottom: 300rpx;
			right: 20rpx;
			width: 110rpx;
			height: 110rpx;
			image{
				width: 110rpx;
				height: 110rpx;
			}
		}
		.serverPop{
			background-color: #FFF;
			padding: 20rpx;
			border-radius: 10rpx;
			.serverPop-tit{
				text-align: center;
				margin-top: 0;
			}
			view{
				margin-top: 20rpx;
				text-align: center;
				image{
					display: inline-block;
					width: 500rpx;
					height: 500rpx;
				}
				text{
					display: inline-block;
					border: solid 1px #2073F5;
					border-radius: 30rpx;
					height: 50rpx;
					line-height: 50rpx;
					color: #2073F5;
					padding: 0 30rpx;
					font-size: 28rpx;
					margin-bottom: 20rpx;
				}
			}
			.tips{
				font-size: 24rpx;
				color: #999;
				margin-top: 0;
				padding-bottom: 20rpx;
			}
		}
	}
	.update-pop{
		width: 540rpx;
		margin: 0 auto;
		.update-close{
			text-align: right;
			margin-bottom: 50rpx;
			padding-right: 20rpx;
			image{
				width: 58rpx;
				height: 58rpx;
			}
		}
		.update-img{
			width: 100%;
			vertical-align: top;
		}
		.update-main{
			background-color: #FFF;
			border-radius: 0 0 10rpx 10rpx;
			overflow: hidden;
			padding: 0 65rpx 40rpx;
			.update-tit{
				margin-bottom: 30rpx;
				font-weight: bold;
				color: #333;
			}
			.update-p{
				margin-bottom: 10rpx;
				color: #666;
			}
			.download{
				display: block;
				margin-top: 30rpx;
			}
		}
	}
</style>